package com.mikeli.javacourse.lesson3.homework.gateway;


import com.mikeli.javacourse.lesson3.homework.gateway.inbound.HttpInboundServer;

public class NettyServerApplication {
    
    public final static String GATEWAY_NAME = "NIOGateway";
    public final static String GATEWAY_VERSION = "1.0.0";

    /**
     * 1. 启动 com.mikeli.javacourse.lesson2.practice.netty.HelloNettyServer
     * 2. 启动当前类
     * 3. 测试类： com.mikeli.javacourse.lesson3.homework.gateway.outbound.netty4.NettyHttpClient
     * HttpRequestURIFilter -> 增加test   path
     * HttpRequestHeaderFilter -> 增加header
     *
     *
     *
     *
     *
     * @param args
     */

    public static void main(String[] args) {
        String proxyServer = System.getProperty("proxyServer","http://localhost:8081");
        String proxyPort = System.getProperty("proxyPort","8888");
        
          //  http://localhost:8888/api/hello  ==> gateway API
          //  http://localhost:8088/api/hello  ==> backend service
    
        int port = Integer.parseInt(proxyPort);
        System.out.println(GATEWAY_NAME + " " + GATEWAY_VERSION +" starting...");
        HttpInboundServer server = new HttpInboundServer(port, proxyServer);
        System.out.println(GATEWAY_NAME + " " + GATEWAY_VERSION +" started at http://localhost:" + port + " for server:" + proxyServer);
        try {
            server.run();
        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
